import axios from "axios";
import SparkMD5 from "spark-md5";
import App from "./App.vue";
import "./style.css";
import { createApp } from "vue";
import { router } from "./common/router.js";
// import { epStore } from './common/store.js'
// import { createPinia } from 'pinia'
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

import { storeEP } from "./common/-store.js";

axios.defaults.baseURL = "http://123.249.0.201";
// axios.defaults.baseURL = "http://localhost:8080"

const app = createApp(App);

app.provide("axios", axios);
// app.provide("epStore", epStore)
app.provide("SparkMD5", SparkMD5);
app.provide("server_url", axios.defaults.baseURL);

app.provide("storeEP", storeEP);

// 使用pinia
// const pinia = createPinia()
// pinia.use(piniaPluginPersistedstate);
// app.use(pinia)
// 使用路由
app.use(router);

const store_data = storeEP.state;
// 拦截器 每一个请求都会执行这一步
axios.interceptors.request.use((req) => {
    req.headers.Authorization = store_data.token;
    return req;
});

app.mount("#app");
